package com.zjcloud.academic.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjcloud.common.annotation.Log;
import com.zjcloud.common.core.controller.BaseController;
import com.zjcloud.common.core.domain.AjaxResult;
import com.zjcloud.common.enums.BusinessType;
import com.zjcloud.academic.domain.ScScheduleResult;
import com.zjcloud.academic.service.IScScheduleResultService;
import com.zjcloud.common.utils.poi.ExcelUtil;
import com.zjcloud.common.core.page.TableDataInfo;

/**
 * 排课结果Controller
 * 
 * @author zjcloud
 */
@RestController
@RequestMapping("/academic/scheduleResult")
public class AcademicScScheduleResultController extends BaseController
{
    @Autowired
    private IScScheduleResultService scScheduleResultService;

    /**
     * 查询排课结果列表
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScScheduleResult scScheduleResult)
    {
        startPage();
        List<ScScheduleResult> list = scScheduleResultService.selectScScheduleResultList(scScheduleResult);
        return getDataTable(list);
    }

    /**
     * 导出排课结果列表
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:export')")
    @Log(title = "排课结果", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ScScheduleResult scScheduleResult)
    {
        List<ScScheduleResult> list = scScheduleResultService.selectScScheduleResultList(scScheduleResult);
        ExcelUtil<ScScheduleResult> util = new ExcelUtil<ScScheduleResult>(ScScheduleResult.class);
        return util.exportExcel(list, "排课结果数据");
    }

    /**
     * 获取排课结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(scScheduleResultService.selectScScheduleResultById(id));
    }

    /**
     * 根据批次获取排课结果
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:query')")
    @GetMapping(value = "/batch/{scheduleBatch}")
    public AjaxResult getByBatch(@PathVariable("scheduleBatch") String scheduleBatch)
    {
        return AjaxResult.success(scScheduleResultService.selectScScheduleResultByBatch(scheduleBatch));
    }

    /**
     * 新增排课结果
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:add')")
    @Log(title = "排课结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScScheduleResult scScheduleResult)
    {
        return toAjax(scScheduleResultService.insertScScheduleResult(scScheduleResult));
    }

    /**
     * 批量新增排课结果
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:add')")
    @Log(title = "排课结果", businessType = BusinessType.INSERT)
    @PostMapping("/batch")
    public AjaxResult batchAdd(@RequestBody List<ScScheduleResult> scScheduleResultList)
    {
        return toAjax(scScheduleResultService.batchInsertScScheduleResult(scScheduleResultList));
    }

    /**
     * 修改排课结果
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:edit')")
    @Log(title = "排课结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScScheduleResult scScheduleResult)
    {
        return toAjax(scScheduleResultService.updateScScheduleResult(scScheduleResult));
    }

    /**
     * 删除排课结果
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:remove')")
    @Log(title = "排课结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scScheduleResultService.deleteScScheduleResultByIds(ids));
    }

    /**
     * 根据批次删除排课结果
     */
    @PreAuthorize("@ss.hasPermi('academic:scheduleResult:remove')")
    @Log(title = "排课结果", businessType = BusinessType.DELETE)
    @DeleteMapping("/batch/{scheduleBatch}")
    public AjaxResult removeByBatch(@PathVariable("scheduleBatch") String scheduleBatch)
    {
        return toAjax(scScheduleResultService.deleteScScheduleResultByBatch(scheduleBatch));
    }
}